
#ifndef _MEMORY_ALLOCATION_H 
#define _MEMORY_ALLOCATION_H    

#include    "common_cfg.h"
#include    "stdint.h"
#include    "typedefs.h"
#include    "cnf_mem_alloc.h"

/* Data type definitions for near memory */
typedef struct 
{
    Mem_RamPagesType            RamPageId;
    tu8Ptr_Near                 ptr_nearCurrentAddress;
    tu8Ptr_Near                 ptr_nearEndAddress;       
    uint16_t                    u16_FreeBytes;
}NearRAM_StatusType;

typedef struct 
{      
    NearRAM_StatusType *      RamPageStatus;
    uint8_t                       u8NumberOfPages;
}NearMemAlloc_StatusType;

/* Data type definitions for far memory */
typedef struct 
{
    Mem_RamPagesType            RamPageId;
    tu8Ptr_Far                  ptr_CurrentAddress;
    tu8Ptr_Far                  ptr_EndAddress;       
    uint16_t                    u16_FreeBytes;
}PagedRAM_StatusType;

typedef struct 
{      
    PagedRAM_StatusType *     RamPageStatus;
    uint8_t                       u8NumberOfPages;
}MemAlloc_StatusType;



#define MEM_ALLOC_1_BYTE_ALIGN  0xFFFF
#define MEM_ALLOC_2_BYTE_ALIGN  0xFFFE
#define MEM_ALLOC_4_BYTE_ALIGN  0xFFFC

void vfnMemAlloc_NearInit( const NearMemAlloc_ConfigType * mem_alloc_config  );

tu8Ptr_Near MemAlloc_NearReserve( uint16_t  u16SizeinBytes);

void vfnMemAlloc_NearErase( tu8Ptr_Near StartAddress , uint16_t  u16SizeinBytes);




void vfnMemAlloc_Init( const MemAlloc_ConfigType * mem_alloc_config  );

tu8Ptr_Far MemAlloc_Reserve( uint16_t  u16SizeinBytes );

void vfnMemAlloc_Erase( tu8Ptr_Far StartAddress , uint16_t  u16SizeinBytes);

#endif /* __MEMORY_ALLOCATION_H */ 